﻿#ifndef CUSTOMGRAPHICSVIEW_H
#define CUSTOMGRAPHICSVIEW_H


#include <QGraphicsView>
#include <QMenu>
#include <QMouseEvent> // 包含 QMouseEvent

class CustomGraphicsView : public QGraphicsView
{
    Q_OBJECT

public:
    explicit CustomGraphicsView(QWidget *parent = nullptr);

protected:
    // 重写右键菜单事件
    void contextMenuEvent(QContextMenuEvent *event) override;
    // 新增：重写鼠标按下事件以实现自定义多选
    void mousePressEvent(QMouseEvent *event) override;

private slots:
    void mergeSelectedRects();
    void toggleEditMode();
    void addRect();                 // 添加矩形
    void deleteSelectedRects();     // 删除选中的矩形
    void splitHorizontally();       // 水平分割
    void splitVertically();         // 垂直分割
private:
    QPointF m_contextMenuScenePos;  // 存储右键菜单的场景坐标
};

#endif // CUSTOMGRAPHICSVIEW_H
